package com.apes.framework.config.elasticsearch;

import org.elasticsearch.client.Client;
import org.springframework.boot.actuate.health.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.Map;

/**
 * 功能：Elasticsearch 配置
 *
 * @author xul
 * @create 2021-01-12 16:04
 */
@Configuration
public class ElasticsearchConfiguration {

    @Bean
    public ApesElasticsearchHealthIndicator apesElasticsearchHealthIndicator(Map<String, Client> clients) {
        if (clients == null || clients.isEmpty()) return null;
        return new ApesElasticsearchHealthIndicator(clients.values().iterator().next(), 100, new ArrayList<>());
    }
}
